import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex)
// 创建一个新的 store 实例

const state = {
  type: '',
  backTheme: true, // 外网控制黑白色系(true为黑色， false为白色系),内网默认为true
  iframeData: null,
  showHome: false,
  loaded: false
};

const actions = {
  tohome(context, payload){
    context.commit('TOHOME', payload)
  },
  toload(context, payload){
    context.commit('TOLOAD', payload)
  },
  tocross(context, payload){
    context.commit('TOCROSS', payload)
  },
  torailway(context, payload){
    context.commit('TORAILWAY', payload)
  },
  tofast(context, payload){
    context.commit('TOFAST', payload)
  },
  toarea(context, payload){
    context.commit('TOAREA', payload)
  },
  toTheme(context, payload){
    context.commit('TOTHEME', payload)
  },
  toIframe(context, payload){
    context.commit('TOIFRAME', payload)
  },
  tonull(context, payload){
    context.commit('TONULL', payload)
  },
  toShowHome(context, payload){
    context.commit('TOSHOWHOME', payload)
  },
};

const mutations = {
  TOHOME(state, payload){
    state.type = 'home'
  },
  TOLOAD(state, payload){
    state.loaded = true
  },
  TOCROSS(state, payload){
    state.type = 'cross'
  },
  TORAILWAY(state, payload){
    state.type = 'railway'
  },
  TOFAST(state, payload){
    state.type = 'fast'
  },
  TOAREA(state, payload){
    state.type = 'area'
  },
  TONULL(state, payload){
    state.type = 'null'
  },
  TOTHEME(state, payload){
    state.backTheme = payload
  },
  TOIFRAME(state, payload){
    state.iframeData = payload
  },
  TOSHOWHOME(state, payload){
    state.showHome = payload
  }
};
export default new Vuex.Store({
  actions,
  mutations,
  state
})





